﻿package mortal.game.view.loginNotice
{
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class LoginNoticeController extends Controller
    {
        private var _loginNoticeWindow:LoginNoticeWindow;

        public function LoginNoticeController()
        {
            return;
        }// end function

        private function onWindowShowHandler(event:WindowEvent) : void
        {
            this.loadVersionData();
            return;
        }// end function

        private function loadVersionData() : void
        {
            LoginNoticeDownload.instance.loadDataFromPhp(ParamsConst.instance.updateUrl, this.onUpdateDataLoaded);
            return;
        }// end function

        private function onUpdateDataLoaded() : void
        {
            (view as LoginNoticeWindow).updataVersion(LoginNoticeDownload.instance.noticeMsg, LoginNoticeDownload.instance.addList, LoginNoticeDownload.instance.updateList);
            return;
        }// end function

        override protected function initServer() : void
        {
            return;
        }// end function

        override protected function initView() : IView
        {
            if (!this._loginNoticeWindow)
            {
                this._loginNoticeWindow = new LoginNoticeWindow();
                this._loginNoticeWindow.addEventListener(WindowEvent.SHOW, this.onWindowShowHandler);
            }
            return this._loginNoticeWindow;
        }// end function

    }
}
